manual event agent validate JSON field before form submit (#1728)

Enfop 7 years ago
parent
commit
8efe50ad99
1 changed files with 7 additions and 0 deletions
  1. 7 0
      app/views/agents/agent_views/manual_event_agent/_show.html.erb

+ 7 - 0
app/views/agents/agent_views/manual_event_agent/_show.html.erb

@@ -30,6 +30,13 @@
30 30
       e.preventDefault();
31 31
       var $form = $("#create-event-form");
32 32
       var $status = $("#event-creation-status");
33
+      try{
34
+        JSON.parse($form.find("textarea").val());
35
+      }
36
+      catch(err){
37
+        alert ('Sorry, there appears to be an error in your JSON input. Please fix it before continuing.');
38
+        return false;
39
+      }
33 40
       $.ajax({
34 41
         url: $form.attr('action'),
35 42
         method: "post",